package com.atwu.wl2022.config;

import com.atwu.wl2022.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截器
 * @author wulejay
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//addPathPatterns拦截的路径
		String[] addPathPatterns = {
				"/comment/**",
				"/root/**",
				"/user/**",
				"/druid/**"
		};
		//excludePathPatterns排除的路径
		String[] excludePathPatterns = {
		};
		//创建用户拦截器对象并指定其拦截的路径和排除的路径
		//固定要拦截的请求，因为是一个半开放的网站
		registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns(addPathPatterns);
	}
}
